﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ec_System.Models.Web;
using Ilongshi.Oversea.DataAccess;

namespace Ec_System.Service.Web
{
    public class VendorShopService
    {
        /// <summary>
        /// 获取明星店铺的信息
        /// </summary>
        /// <returns></returns>
        public List<VendorShopData> GetTop9Shop()
        {
            var cmd = DataCommandManager.GetDataCommand("GetTop9Shop");

            return cmd.ExecuteEntityList<VendorShopData>();
        }

        /// <summary>
        /// 根据商品ID获取其附属信息
        /// </summary>
        /// <param name="productID"></param>
        /// <returns></returns>
        public ShopProductData GetProductInfoByID(int productID)
        {
            var cmd = DataCommandManager.GetDataCommand("GetProductInfoByID");
            cmd.SetParameterValue("@ProductID", productID);

            return cmd.ExecuteEntity<ShopProductData>();
        }

        /// <summary>
        /// 根据店铺ID取得该店铺销量前5
        /// </summary>
        /// <param name="shopID"></param>
        /// <returns></returns>
        public List<ShopProductData> GetShopTop5ByShopID(string shopID)
        {
            var cmd = DataCommandManager.GetDataCommand("GetShopTop5ByShopID");
            cmd.SetParameterValue("ShopID", shopID);

            return cmd.ExecuteEntityList<ShopProductData>();
        }

        /// <summary>
        /// 获取店铺列表--带分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public VendorShopResponseData GetShopListWithPage(int pageIndex, int pageSize)
        {
            var cmd = DataCommandManager.GetDataCommand("GetShopListWithPage");
            cmd.SetParameterValue("@PageIndex", pageIndex);
            cmd.SetParameterValue("@PageSize", pageSize);

            return new VendorShopResponseData()
            {
                PageIndex = pageIndex,
                PageSize = pageSize,                
                Result = cmd.ExecuteEntityList<VendorShopData>(),
                TotalCount = cmd.GetParameterValue<int>("@TotalCount")
            };
        }

        /// <summary>
        /// 根据店铺ID获取其详情
        /// </summary>
        /// <param name="shopID"></param>
        /// <returns></returns>
        public VendorShopData GetShopDetailByID(int shopID)
        {
            var cmd = DataCommandManager.GetDataCommand("GetShopDetailByID");
            cmd.SetParameterValue("@ShopID", shopID);

            return cmd.ExecuteEntity<VendorShopData>();
        }

    }
}
